@extends('layouts.common_no_menu')

@section('title')调拨增加/修改@endsection
@section('css')
    <style>
        .info-form td {margin-right: 10px;}
        .input_width {width: 90px;}
    </style>
@endsection

@section('content')
<body class="easyui-layout">
<div data-options="region:'north'" style="padding:5px;">
    <form id="info-form" method="post">
        <table>
            <tr>
                <td>调拨类型:<input type="text" name="doctype_id" class="easyui-textbox input_width" /></td>
                <td>调拨日期:<input type="text" name="movementdate" class="easyui-textbox input_width" /></td>
                <td>调出仓库:<input class="easyui-combobox input_width" type="text" id="warehouse" name="warehouse_id" /></td>
                <td>调入仓库:<input class="easyui-combobox input_width" type="text" id="warehouse1" name="warehouseto_id" /></td>
                <div style="clear: both"></div>
            </tr>
            <tr>
                <td colspan="3">调拨描述:<input class="easyui-textbox" name="description" id="description" value="" style="width:350px;height:70px"></td>
                <td><a href="#" class="easyui-linkbutton" iconCls="icon-add" onclick="reqAdd()" plain="true">添加</a></td>
            </tr>
        </table>
    </form>
</div>

</body>
@endsection

@section('js')
<script type="text/javascript">
    $('#warehouse').combobox({
        url: '/storage/warehouse/warehouselist',
        method: 'get',
        valueField: 'id',
        textField: 'name',
        panelMaxHeight:90
    });
    $('#warehouse1').combobox({
        url: '/storage/warehouse/warehouselist',
        method: 'get',
        valueField: 'id',
        textField: 'name',
        panelMaxHeight:90
    });

    function reqAdd(){
        var count = 0;
        $("#info-form").find('input').each(function() {
            if ($(this).val()==='') {
                count++;
                $.messager.alert("提示信息","当前项目不能有空项!");
                $(this).focus();
                return false;
            }
        });
        $.ajax({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            url:'/storage/movement/movementadd',
            type:'post',
            data:$('#info-form').serialize(),
            dataType:'json',
            success:function (data) {
                if(data.code === 200){
                    $("input[name='req_id']").val(data.id);
                    goodsAdd();
                }else{
                    $.messager.alert("提示信息", data.data , "error");
                    return false;
                }
            }
        });

    }
    function goodsAdd(){
        $('#form_dialog').dialog({
            title: '添加信息',
            width: 500,
            height: 200,
            closed: false,
            cache: false,
            href: '/sale/requisition/goodsadd',
            modal: true,
            buttons: [{
                text: '确定',
                iconCls: 'icon-ok',
                handler: save
            }, {
                text: '取消',
                iconCls: 'icon-cancel',
                handler: function () {
                    $('#form_dialog').dialog('close');
                }
            }]
        });     
    }
</script>
@endsection

